package com.docios.cookbook2.utils;

import android.annotation.SuppressLint;
import android.os.CountDownTimer;
import android.widget.Button;

public class CountDownUtil extends CountDownTimer {
    Button button;

    public CountDownUtil(long millisInFuture, long countDownInterval,Button btn) {
        super(millisInFuture, countDownInterval);

        this.button=btn;
    }

    //开始计时
    @SuppressLint("SetTextI18n")
    @Override
    public void onTick(long l) {
        //禁止点击
        button.setClickable(false);
        button.setText(l / 1000 + "s后再获取");
    }

    //计时结束
    @Override
    public void onFinish() {
        button.setText("重新获取");
        button.setClickable(true);
    }
}
